Skip to content

Conversation

@carols10cents
Copy link
Member

Don't show the link if there aren't any docs.rs builds as clicking on the link won't work then, but do still show the source link even if a non-docs.rs documentation link has been specified to enable review of the source exactly as crates.io serves it.

@Turbo87 Turbo87 added the C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works label Dec 19, 2025
@carols10cents carols10cents moved this to For next meeting in crates.io team meetings Dec 19, 2025
@carols10cents carols10cents force-pushed the source-link branch 2 times, most recently from c583304 to bf6d458 Compare December 23, 2025 16:41
Don't show the link if there aren't any docs.rs builds as clicking on
the link won't work then, but do still show the source link even if a
non-docs.rs documentation link has been specified to enable review of
the source exactly as crates.io serves it.
@carols10cents
Copy link
Member Author

@Turbo87 i quit. I can't figure out why the remaining one qunit and one e2e tests are failing; i added the mock docs.rs requests exactly like in the other tests that are passing, but the source link isn't showing up and I don't understand why.

The source link is showing up in some of the percy screenshots as expected, but it also looks like the main baseline in percy has some 404 pages saved?

I also can't get the frontend working locally proxying to the live crates.io; when I run the frontend everything looks fine:

❯ pnpm start:live

> [email protected] start:live /Users/carolnichols/rust/crates.io
> ember serve --proxy https://crates.io

WARNING: ember-cli-typescript requires ember-cli-babel ^7.17.0, but you have version 8.2.0 installed; your TypeScript files may not be transpiled correctly.
The setting 'staticEmberSource' will default to true in the next version of Embroider and can't be turned off. To prepare for this you should set 'staticEmberSource: true' in your Embroider config.
Proxying to https://crates.io

Build successful (8867ms) – Serving on http://localhost:4200/

Slowest Nodes (totalTime >= 5%)                                     | Total (avg)
--------------------------------------------------------------------+-----------------
@embroider/webpack (1)                                              | 8124ms

but when i visit localhost:4200/crates/rand for example, it shows the "Failed to load crate data" generic javascript error message (in both firefox and chrome).

In firefox, there aren't any errors showing up in the web development tools console, but if i open tools -> browser tools -> browser console, i see:

13:15:05.957 Unable to find target with innerWindowId:1726576852995 watcher.js:196:13
    getWindowGlobalTargetByInnerWindowId resource://devtools/client/fronts/watcher.js:196
    _getTargetForWatcherResource resource://devtools/shared/commands/resource/resource-command.js:984
    _onResourceUpdated resource://devtools/shared/commands/resource/resource-command.js:843
    _onResourceUpdatedArray resource://devtools/shared/commands/resource/resource-command.js:767
    _emit resource://devtools/shared/event-emitter.js:215
    emit resource://devtools/shared/event-emitter.js:152
    onPacket resource://devtools/shared/protocol/Front.js:370
    onPacket resource://devtools/client/devtools-client.js:511
    send resource://devtools/shared/transport/local-transport.js:73
    makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103
    makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103

and in chrome i don't see any console errors:

Screenshot 2025-12-23 at 1 19 04 PM

if I make this change in app/routes/crate.js:

    } catch (error) {
      if (error instanceof NotFoundError) {
        let title = `Crate "${crateName}" not found`;
        this.router.replaceWith('catch-all', { transition, error, title });
      } else {
        console.log(error);
        let title = `Failed to load crate data`;
        this.router.replaceWith('catch-all', { transition, error, title, tryAgain: true });
      }
    }

THEN i see:

13:21:07.998 Error: Could not find module `@ember-data/private-build-infra/src/addon-build-config-for-data-package` imported from `(require)`
    missingModule loader.js:247
    findModule loader.js:258
    requireModule loader.js:24
    Ember 2
    __webpack_require__ chunk.1af291960aa7c517d83b.js:37
    <anonymous> crate.js:10
    js chunk.a49f0f1516ee6450233a.js:11357
    __webpack_require__ chunk.1af291960aa7c517d83b.js:37
    <anonymous> crates-io.js:68
    exports loader.js:106
    requireModule loader.js:27
    get Ember
crate.js:52:17

which... wtf????? what am i doing wrong?????????

@carols10cents
Copy link
Member Author

oh ffs nevermind... i did the good old "blow away node_modules" and now i can load a local page proxying to crates.io.

@carols10cents
Copy link
Member Author

ok yeah even with getting this running locally i still dont understand why this code isn't working.

if i go to a crate like rand that doesn't have crate.documentation set, this code works fine.

if i go to a crate like ripgrep that does have crate.documentation set, this.loadDocsStatusTask is just... undefined and i have no idea why 😢

@Turbo87
Copy link
Member

Turbo87 commented Dec 23, 2025

I'll take a look once I'm back at a computer :)

@Turbo87
Copy link
Member

Turbo87 commented Dec 27, 2025

I think what you're looking for is:

if (!crate.documentation || crate.documentation.startsWith('https://docs.rs/')) {
version.loadDocsStatusTask.perform().catch(error => {
// report unexpected errors to Sentry and ignore `ajax()` errors
if (!didCancel(error) && !(error instanceof AjaxError)) {
this.sentry.captureException(error);
}
});
}

the loadDocsStatusTask is only "performed" if we know that the docs are hosted on docs.rs. for ripgrep the docs link points to https://github.com/BurntSushi/ripgrep, which is why the task isn't run.

@carols10cents
Copy link
Member Author

the loadDocsStatusTask is only "performed" if we know that the docs are hosted on docs.rs. for ripgrep the docs link points to BurntSushi/ripgrep, which is why the task isn't run.

😢

Even if the crate has a documentation link specified, we want to show a
link to the source view of docs.rs. But we still want to check that
docs.rs has had a chance to build the crate's docs before we add the
link to browse the source, so we do need to make this request.
@carols10cents
Copy link
Member Author

Ok-- this looks like it's working the way i intended now, aside from the expected percy differences. Ready for rereview @Turbo87 , thank you for your help!!

Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! :)

@Turbo87 Turbo87 merged commit bca17b4 into rust-lang:main Jan 2, 2026
14 checks passed
@carols10cents carols10cents deleted the source-link branch January 4, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-frontend 🐹 C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants